/* 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 { CertificateKeyPairKeyTypeEnum } from "./CertificateKeyPairKeyTypeEnum";
import { CertificateKeyPairKeyTypeEnumFromJSON } from "./CertificateKeyPairKeyTypeEnum";

/**
 * CertificateKeyPair Serializer
 * @export
 * @interface CertificateKeyPair
 */
export interface CertificateKeyPair {
    /**
     *
     * @type {string}
     * @memberof CertificateKeyPair
     */
    readonly pk: string;
    /**
     *
     * @type {string}
     * @memberof CertificateKeyPair
     */
    name: string;
    /**
     * SHA256 fingerprint of the certificate
     * @type {string}
     * @memberof CertificateKeyPair
     */
    readonly fingerprintSha256: string | null;
    /**
     * SHA1 fingerprint of the certificate
     * @type {string}
     * @memberof CertificateKeyPair
     */
    readonly fingerprintSha1: string | null;
    /**
     * Certificate expiry date
     * @type {Date}
     * @memberof CertificateKeyPair
     */
    readonly certExpiry: Date | null;
    /**
     * Certificate subject as RFC4514 string
     * @type {string}
     * @memberof CertificateKeyPair
     */
    readonly certSubject: string | null;
    /**
     * Show if this keypair has a private key configured or not
     * @type {boolean}
     * @memberof CertificateKeyPair
     */
    readonly privateKeyAvailable: boolean;
    /**
     * Key algorithm type detected from the certificate's public key
     * @type {CertificateKeyPairKeyTypeEnum}
     * @memberof CertificateKeyPair
     */
    readonly keyType: CertificateKeyPairKeyTypeEnum | null;
    /**
     * Get URL to download certificate
     * @type {string}
     * @memberof CertificateKeyPair
     */
    readonly certificateDownloadUrl: string;
    /**
     * Get URL to download private key
     * @type {string}
     * @memberof CertificateKeyPair
     */
    readonly privateKeyDownloadUrl: string;
    /**
     * Objects that are managed by authentik. These objects are created and updated automatically. This flag only indicates that an object can be overwritten by migrations. You can still modify the objects via the API, but expect changes to be overwritten in a later update.
     * @type {string}
     * @memberof CertificateKeyPair
     */
    readonly managed: string | null;
}

/**
 * Check if a given object implements the CertificateKeyPair interface.
 */
export function instanceOfCertificateKeyPair(value: object): value is CertificateKeyPair {
    if (!("pk" in value) || value["pk"] === undefined) return false;
    if (!("name" in value) || value["name"] === undefined) return false;
    if (!("fingerprintSha256" in value) || value["fingerprintSha256"] === undefined) return false;
    if (!("fingerprintSha1" in value) || value["fingerprintSha1"] === undefined) return false;
    if (!("certExpiry" in value) || value["certExpiry"] === undefined) return false;
    if (!("certSubject" in value) || value["certSubject"] === undefined) return false;
    if (!("privateKeyAvailable" in value) || value["privateKeyAvailable"] === undefined)
        return false;
    if (!("keyType" in value) || value["keyType"] === undefined) return false;
    if (!("certificateDownloadUrl" in value) || value["certificateDownloadUrl"] === undefined)
        return false;
    if (!("privateKeyDownloadUrl" in value) || value["privateKeyDownloadUrl"] === undefined)
        return false;
    if (!("managed" in value) || value["managed"] === undefined) return false;
    return true;
}

export function CertificateKeyPairFromJSON(json: any): CertificateKeyPair {
    return CertificateKeyPairFromJSONTyped(json, false);
}

export function CertificateKeyPairFromJSONTyped(
    json: any,
    ignoreDiscriminator: boolean,
): CertificateKeyPair {
    if (json == null) {
        return json;
    }
    return {
        pk: json["pk"],
        name: json["name"],
        fingerprintSha256: json["fingerprint_sha256"],
        fingerprintSha1: json["fingerprint_sha1"],
        certExpiry: json["cert_expiry"] == null ? null : new Date(json["cert_expiry"]),
        certSubject: json["cert_subject"],
        privateKeyAvailable: json["private_key_available"],
        keyType: CertificateKeyPairKeyTypeEnumFromJSON(json["key_type"]),
        certificateDownloadUrl: json["certificate_download_url"],
        privateKeyDownloadUrl: json["private_key_download_url"],
        managed: json["managed"],
    };
}

export function CertificateKeyPairToJSON(json: any): CertificateKeyPair {
    return CertificateKeyPairToJSONTyped(json, false);
}

export function CertificateKeyPairToJSONTyped(
    value?: Omit<
        CertificateKeyPair,
        | "pk"
        | "fingerprint_sha256"
        | "fingerprint_sha1"
        | "cert_expiry"
        | "cert_subject"
        | "private_key_available"
        | "key_type"
        | "certificate_download_url"
        | "private_key_download_url"
        | "managed"
    > | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }

    return {
        name: value["name"],
    };
}
