/* 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 {
    CertificateData,
    CertificateGenerationRequest,
    CertificateKeyPair,
    CertificateKeyPairRequest,
    KeyTypeEnum,
    PaginatedCertificateKeyPairList,
    PatchedCertificateKeyPairRequest,
    UsedBy,
} from "../models/index";
import {
    CertificateDataFromJSON,
    CertificateGenerationRequestToJSON,
    CertificateKeyPairFromJSON,
    CertificateKeyPairRequestToJSON,
    PaginatedCertificateKeyPairListFromJSON,
    PatchedCertificateKeyPairRequestToJSON,
    UsedByFromJSON,
} from "../models/index";
import * as runtime from "../runtime";

export interface CryptoCertificatekeypairsCreateRequest {
    certificateKeyPairRequest: CertificateKeyPairRequest;
}

export interface CryptoCertificatekeypairsDestroyRequest {
    kpUuid: string;
}

export interface CryptoCertificatekeypairsGenerateCreateRequest {
    certificateGenerationRequest: CertificateGenerationRequest;
}

export interface CryptoCertificatekeypairsListRequest {
    hasKey?: boolean;
    keyType?: Array<KeyTypeEnum>;
    managed?: string;
    name?: string;
    ordering?: string;
    page?: number;
    pageSize?: number;
    search?: string;
}

export interface CryptoCertificatekeypairsPartialUpdateRequest {
    kpUuid: string;
    patchedCertificateKeyPairRequest?: PatchedCertificateKeyPairRequest;
}

export interface CryptoCertificatekeypairsRetrieveRequest {
    kpUuid: string;
}

export interface CryptoCertificatekeypairsUpdateRequest {
    kpUuid: string;
    certificateKeyPairRequest: CertificateKeyPairRequest;
}

export interface CryptoCertificatekeypairsUsedByListRequest {
    kpUuid: string;
}

export interface CryptoCertificatekeypairsViewCertificateRetrieveRequest {
    kpUuid: string;
    download?: boolean;
}

export interface CryptoCertificatekeypairsViewPrivateKeyRetrieveRequest {
    kpUuid: string;
    download?: boolean;
}

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

        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 = `/crypto/certificatekeypairs/`;

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

    /**
     * CertificateKeyPair Viewset
     */
    async cryptoCertificatekeypairsCreateRaw(
        requestParameters: CryptoCertificatekeypairsCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<CertificateKeyPair>> {
        const requestOptions =
            await this.cryptoCertificatekeypairsCreateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * CertificateKeyPair Viewset
     */
    async cryptoCertificatekeypairsCreate(
        requestParameters: CryptoCertificatekeypairsCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<CertificateKeyPair> {
        const response = await this.cryptoCertificatekeypairsCreateRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

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

        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 = `/crypto/certificatekeypairs/{kp_uuid}/`;
        urlPath = urlPath.replace(
            `{${"kp_uuid"}}`,
            encodeURIComponent(String(requestParameters["kpUuid"])),
        );

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

    /**
     * CertificateKeyPair Viewset
     */
    async cryptoCertificatekeypairsDestroyRaw(
        requestParameters: CryptoCertificatekeypairsDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<void>> {
        const requestOptions =
            await this.cryptoCertificatekeypairsDestroyRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     * CertificateKeyPair Viewset
     */
    async cryptoCertificatekeypairsDestroy(
        requestParameters: CryptoCertificatekeypairsDestroyRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<void> {
        await this.cryptoCertificatekeypairsDestroyRaw(requestParameters, initOverrides);
    }

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

        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 = `/crypto/certificatekeypairs/generate/`;

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

    /**
     * Generate a new, self-signed certificate-key pair
     */
    async cryptoCertificatekeypairsGenerateCreateRaw(
        requestParameters: CryptoCertificatekeypairsGenerateCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<CertificateKeyPair>> {
        const requestOptions =
            await this.cryptoCertificatekeypairsGenerateCreateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * Generate a new, self-signed certificate-key pair
     */
    async cryptoCertificatekeypairsGenerateCreate(
        requestParameters: CryptoCertificatekeypairsGenerateCreateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<CertificateKeyPair> {
        const response = await this.cryptoCertificatekeypairsGenerateCreateRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

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

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

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

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

        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 = `/crypto/certificatekeypairs/`;

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

    /**
     * CertificateKeyPair Viewset
     */
    async cryptoCertificatekeypairsListRaw(
        requestParameters: CryptoCertificatekeypairsListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<PaginatedCertificateKeyPairList>> {
        const requestOptions =
            await this.cryptoCertificatekeypairsListRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * CertificateKeyPair Viewset
     */
    async cryptoCertificatekeypairsList(
        requestParameters: CryptoCertificatekeypairsListRequest = {},
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<PaginatedCertificateKeyPairList> {
        const response = await this.cryptoCertificatekeypairsListRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

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

        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 = `/crypto/certificatekeypairs/{kp_uuid}/`;
        urlPath = urlPath.replace(
            `{${"kp_uuid"}}`,
            encodeURIComponent(String(requestParameters["kpUuid"])),
        );

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

    /**
     * CertificateKeyPair Viewset
     */
    async cryptoCertificatekeypairsPartialUpdateRaw(
        requestParameters: CryptoCertificatekeypairsPartialUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<CertificateKeyPair>> {
        const requestOptions =
            await this.cryptoCertificatekeypairsPartialUpdateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * CertificateKeyPair Viewset
     */
    async cryptoCertificatekeypairsPartialUpdate(
        requestParameters: CryptoCertificatekeypairsPartialUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<CertificateKeyPair> {
        const response = await this.cryptoCertificatekeypairsPartialUpdateRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

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

        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 = `/crypto/certificatekeypairs/{kp_uuid}/`;
        urlPath = urlPath.replace(
            `{${"kp_uuid"}}`,
            encodeURIComponent(String(requestParameters["kpUuid"])),
        );

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

    /**
     * CertificateKeyPair Viewset
     */
    async cryptoCertificatekeypairsRetrieveRaw(
        requestParameters: CryptoCertificatekeypairsRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<CertificateKeyPair>> {
        const requestOptions =
            await this.cryptoCertificatekeypairsRetrieveRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * CertificateKeyPair Viewset
     */
    async cryptoCertificatekeypairsRetrieve(
        requestParameters: CryptoCertificatekeypairsRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<CertificateKeyPair> {
        const response = await this.cryptoCertificatekeypairsRetrieveRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

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

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

        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 = `/crypto/certificatekeypairs/{kp_uuid}/`;
        urlPath = urlPath.replace(
            `{${"kp_uuid"}}`,
            encodeURIComponent(String(requestParameters["kpUuid"])),
        );

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

    /**
     * CertificateKeyPair Viewset
     */
    async cryptoCertificatekeypairsUpdateRaw(
        requestParameters: CryptoCertificatekeypairsUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<CertificateKeyPair>> {
        const requestOptions =
            await this.cryptoCertificatekeypairsUpdateRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * CertificateKeyPair Viewset
     */
    async cryptoCertificatekeypairsUpdate(
        requestParameters: CryptoCertificatekeypairsUpdateRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<CertificateKeyPair> {
        const response = await this.cryptoCertificatekeypairsUpdateRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

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

        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 = `/crypto/certificatekeypairs/{kp_uuid}/used_by/`;
        urlPath = urlPath.replace(
            `{${"kp_uuid"}}`,
            encodeURIComponent(String(requestParameters["kpUuid"])),
        );

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

    /**
     * Get a list of all objects that use this object
     */
    async cryptoCertificatekeypairsUsedByListRaw(
        requestParameters: CryptoCertificatekeypairsUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<Array<UsedBy>>> {
        const requestOptions =
            await this.cryptoCertificatekeypairsUsedByListRequestOpts(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 cryptoCertificatekeypairsUsedByList(
        requestParameters: CryptoCertificatekeypairsUsedByListRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<Array<UsedBy>> {
        const response = await this.cryptoCertificatekeypairsUsedByListRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

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

        const queryParameters: any = {};

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

        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 = `/crypto/certificatekeypairs/{kp_uuid}/view_certificate/`;
        urlPath = urlPath.replace(
            `{${"kp_uuid"}}`,
            encodeURIComponent(String(requestParameters["kpUuid"])),
        );

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

    /**
     * Return certificate-key pairs certificate and log access
     */
    async cryptoCertificatekeypairsViewCertificateRetrieveRaw(
        requestParameters: CryptoCertificatekeypairsViewCertificateRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<CertificateData>> {
        const requestOptions =
            await this.cryptoCertificatekeypairsViewCertificateRetrieveRequestOpts(
                requestParameters,
            );
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * Return certificate-key pairs certificate and log access
     */
    async cryptoCertificatekeypairsViewCertificateRetrieve(
        requestParameters: CryptoCertificatekeypairsViewCertificateRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<CertificateData> {
        const response = await this.cryptoCertificatekeypairsViewCertificateRetrieveRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }

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

        const queryParameters: any = {};

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

        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 = `/crypto/certificatekeypairs/{kp_uuid}/view_private_key/`;
        urlPath = urlPath.replace(
            `{${"kp_uuid"}}`,
            encodeURIComponent(String(requestParameters["kpUuid"])),
        );

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

    /**
     * Return certificate-key pairs private key and log access
     */
    async cryptoCertificatekeypairsViewPrivateKeyRetrieveRaw(
        requestParameters: CryptoCertificatekeypairsViewPrivateKeyRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<runtime.ApiResponse<CertificateData>> {
        const requestOptions =
            await this.cryptoCertificatekeypairsViewPrivateKeyRetrieveRequestOpts(
                requestParameters,
            );
        const response = await this.request(requestOptions, initOverrides);

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

    /**
     * Return certificate-key pairs private key and log access
     */
    async cryptoCertificatekeypairsViewPrivateKeyRetrieve(
        requestParameters: CryptoCertificatekeypairsViewPrivateKeyRetrieveRequest,
        initOverrides?: RequestInit | runtime.InitOverrideFunction,
    ): Promise<CertificateData> {
        const response = await this.cryptoCertificatekeypairsViewPrivateKeyRetrieveRaw(
            requestParameters,
            initOverrides,
        );
        return await response.value();
    }
}
