/* 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 { EndpointAuthModeEnum } from "./EndpointAuthModeEnum";
import { EndpointAuthModeEnumFromJSON, EndpointAuthModeEnumToJSON } from "./EndpointAuthModeEnum";
import type { ProtocolEnum } from "./ProtocolEnum";
import { ProtocolEnumFromJSON, ProtocolEnumToJSON } from "./ProtocolEnum";
import type { RACProvider } from "./RACProvider";
import { RACProviderFromJSON } from "./RACProvider";

/**
 * Endpoint Serializer
 * @export
 * @interface Endpoint
 */
export interface Endpoint {
    /**
     *
     * @type {string}
     * @memberof Endpoint
     */
    readonly pk: string;
    /**
     *
     * @type {string}
     * @memberof Endpoint
     */
    name: string;
    /**
     *
     * @type {number}
     * @memberof Endpoint
     */
    provider: number;
    /**
     *
     * @type {RACProvider}
     * @memberof Endpoint
     */
    readonly providerObj: RACProvider;
    /**
     *
     * @type {ProtocolEnum}
     * @memberof Endpoint
     */
    protocol: ProtocolEnum;
    /**
     *
     * @type {string}
     * @memberof Endpoint
     */
    host: string;
    /**
     *
     * @type {{ [key: string]: any; }}
     * @memberof Endpoint
     */
    settings?: { [key: string]: any };
    /**
     *
     * @type {Array<string>}
     * @memberof Endpoint
     */
    propertyMappings?: Array<string>;
    /**
     *
     * @type {EndpointAuthModeEnum}
     * @memberof Endpoint
     */
    authMode: EndpointAuthModeEnum;
    /**
     * Build actual launch URL (the provider itself does not have one, just
     * individual endpoints)
     * @type {string}
     * @memberof Endpoint
     */
    readonly launchUrl: string | null;
    /**
     *
     * @type {number}
     * @memberof Endpoint
     */
    maximumConnections?: number;
}

/**
 * Check if a given object implements the Endpoint interface.
 */
export function instanceOfEndpoint(value: object): value is Endpoint {
    if (!("pk" in value) || value["pk"] === undefined) return false;
    if (!("name" in value) || value["name"] === undefined) return false;
    if (!("provider" in value) || value["provider"] === undefined) return false;
    if (!("providerObj" in value) || value["providerObj"] === undefined) return false;
    if (!("protocol" in value) || value["protocol"] === undefined) return false;
    if (!("host" in value) || value["host"] === undefined) return false;
    if (!("authMode" in value) || value["authMode"] === undefined) return false;
    if (!("launchUrl" in value) || value["launchUrl"] === undefined) return false;
    return true;
}

export function EndpointFromJSON(json: any): Endpoint {
    return EndpointFromJSONTyped(json, false);
}

export function EndpointFromJSONTyped(json: any, ignoreDiscriminator: boolean): Endpoint {
    if (json == null) {
        return json;
    }
    return {
        pk: json["pk"],
        name: json["name"],
        provider: json["provider"],
        providerObj: RACProviderFromJSON(json["provider_obj"]),
        protocol: ProtocolEnumFromJSON(json["protocol"]),
        host: json["host"],
        settings: json["settings"] == null ? undefined : json["settings"],
        propertyMappings: json["property_mappings"] == null ? undefined : json["property_mappings"],
        authMode: EndpointAuthModeEnumFromJSON(json["auth_mode"]),
        launchUrl: json["launch_url"],
        maximumConnections:
            json["maximum_connections"] == null ? undefined : json["maximum_connections"],
    };
}

export function EndpointToJSON(json: any): Endpoint {
    return EndpointToJSONTyped(json, false);
}

export function EndpointToJSONTyped(
    value?: Omit<Endpoint, "pk" | "provider_obj" | "launch_url"> | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }

    return {
        name: value["name"],
        provider: value["provider"],
        protocol: ProtocolEnumToJSON(value["protocol"]),
        host: value["host"],
        settings: value["settings"],
        property_mappings: value["propertyMappings"],
        auth_mode: EndpointAuthModeEnumToJSON(value["authMode"]),
        maximum_connections: value["maximumConnections"],
    };
}
