/* 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 { AuthenticationEnum } from "./AuthenticationEnum";
import { AuthenticationEnumFromJSON, AuthenticationEnumToJSON } from "./AuthenticationEnum";
import type { DeniedActionEnum } from "./DeniedActionEnum";
import { DeniedActionEnumFromJSON, DeniedActionEnumToJSON } from "./DeniedActionEnum";
import type { FlowDesignationEnum } from "./FlowDesignationEnum";
import { FlowDesignationEnumFromJSON, FlowDesignationEnumToJSON } from "./FlowDesignationEnum";
import type { FlowLayoutEnum } from "./FlowLayoutEnum";
import { FlowLayoutEnumFromJSON, FlowLayoutEnumToJSON } from "./FlowLayoutEnum";
import type { PolicyEngineMode } from "./PolicyEngineMode";
import { PolicyEngineModeFromJSON, PolicyEngineModeToJSON } from "./PolicyEngineMode";
import type { ThemedUrls } from "./ThemedUrls";
import { ThemedUrlsFromJSON } from "./ThemedUrls";

/**
 * Flow Serializer
 * @export
 * @interface Flow
 */
export interface Flow {
    /**
     *
     * @type {string}
     * @memberof Flow
     */
    readonly pk: string;
    /**
     *
     * @type {string}
     * @memberof Flow
     */
    readonly policybindingmodelPtrId: string;
    /**
     *
     * @type {string}
     * @memberof Flow
     */
    name: string;
    /**
     * Visible in the URL.
     * @type {string}
     * @memberof Flow
     */
    slug: string;
    /**
     * Shown as the Title in Flow pages.
     * @type {string}
     * @memberof Flow
     */
    title: string;
    /**
     * Decides what this Flow is used for. For example, the Authentication flow is redirect to when an un-authenticated user visits authentik.
     * @type {FlowDesignationEnum}
     * @memberof Flow
     */
    designation: FlowDesignationEnum;
    /**
     * Background shown during execution
     * @type {string}
     * @memberof Flow
     */
    background?: string;
    /**
     * Get the URL to the background image
     * @type {string}
     * @memberof Flow
     */
    readonly backgroundUrl: string;
    /**
     *
     * @type {ThemedUrls}
     * @memberof Flow
     */
    readonly backgroundThemedUrls: ThemedUrls | null;
    /**
     *
     * @type {Array<string>}
     * @memberof Flow
     */
    readonly stages: Array<string>;
    /**
     *
     * @type {Array<string>}
     * @memberof Flow
     */
    readonly policies: Array<string>;
    /**
     * Get count of cached flows
     * @type {number}
     * @memberof Flow
     */
    readonly cacheCount: number;
    /**
     *
     * @type {PolicyEngineMode}
     * @memberof Flow
     */
    policyEngineMode?: PolicyEngineMode;
    /**
     * Enable compatibility mode, increases compatibility with password managers on mobile devices.
     * @type {boolean}
     * @memberof Flow
     */
    compatibilityMode?: boolean;
    /**
     * Get export URL for flow
     * @type {string}
     * @memberof Flow
     */
    readonly exportUrl: string;
    /**
     *
     * @type {FlowLayoutEnum}
     * @memberof Flow
     */
    layout?: FlowLayoutEnum;
    /**
     * Configure what should happen when a flow denies access to a user.
     * @type {DeniedActionEnum}
     * @memberof Flow
     */
    deniedAction?: DeniedActionEnum;
    /**
     * Required level of authentication and authorization to access a flow.
     * @type {AuthenticationEnum}
     * @memberof Flow
     */
    authentication?: AuthenticationEnum;
}

/**
 * Check if a given object implements the Flow interface.
 */
export function instanceOfFlow(value: object): value is Flow {
    if (!("pk" in value) || value["pk"] === undefined) return false;
    if (!("policybindingmodelPtrId" in value) || value["policybindingmodelPtrId"] === undefined)
        return false;
    if (!("name" in value) || value["name"] === undefined) return false;
    if (!("slug" in value) || value["slug"] === undefined) return false;
    if (!("title" in value) || value["title"] === undefined) return false;
    if (!("designation" in value) || value["designation"] === undefined) return false;
    if (!("backgroundUrl" in value) || value["backgroundUrl"] === undefined) return false;
    if (!("backgroundThemedUrls" in value) || value["backgroundThemedUrls"] === undefined)
        return false;
    if (!("stages" in value) || value["stages"] === undefined) return false;
    if (!("policies" in value) || value["policies"] === undefined) return false;
    if (!("cacheCount" in value) || value["cacheCount"] === undefined) return false;
    if (!("exportUrl" in value) || value["exportUrl"] === undefined) return false;
    return true;
}

export function FlowFromJSON(json: any): Flow {
    return FlowFromJSONTyped(json, false);
}

export function FlowFromJSONTyped(json: any, ignoreDiscriminator: boolean): Flow {
    if (json == null) {
        return json;
    }
    return {
        pk: json["pk"],
        policybindingmodelPtrId: json["policybindingmodel_ptr_id"],
        name: json["name"],
        slug: json["slug"],
        title: json["title"],
        designation: FlowDesignationEnumFromJSON(json["designation"]),
        background: json["background"] == null ? undefined : json["background"],
        backgroundUrl: json["background_url"],
        backgroundThemedUrls: ThemedUrlsFromJSON(json["background_themed_urls"]),
        stages: json["stages"],
        policies: json["policies"],
        cacheCount: json["cache_count"],
        policyEngineMode:
            json["policy_engine_mode"] == null
                ? undefined
                : PolicyEngineModeFromJSON(json["policy_engine_mode"]),
        compatibilityMode:
            json["compatibility_mode"] == null ? undefined : json["compatibility_mode"],
        exportUrl: json["export_url"],
        layout: json["layout"] == null ? undefined : FlowLayoutEnumFromJSON(json["layout"]),
        deniedAction:
            json["denied_action"] == null
                ? undefined
                : DeniedActionEnumFromJSON(json["denied_action"]),
        authentication:
            json["authentication"] == null
                ? undefined
                : AuthenticationEnumFromJSON(json["authentication"]),
    };
}

export function FlowToJSON(json: any): Flow {
    return FlowToJSONTyped(json, false);
}

export function FlowToJSONTyped(
    value?: Omit<
        Flow,
        | "pk"
        | "policybindingmodel_ptr_id"
        | "background_url"
        | "background_themed_urls"
        | "stages"
        | "policies"
        | "cache_count"
        | "export_url"
    > | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }

    return {
        name: value["name"],
        slug: value["slug"],
        title: value["title"],
        designation: FlowDesignationEnumToJSON(value["designation"]),
        background: value["background"],
        policy_engine_mode: PolicyEngineModeToJSON(value["policyEngineMode"]),
        compatibility_mode: value["compatibilityMode"],
        layout: FlowLayoutEnumToJSON(value["layout"]),
        denied_action: DeniedActionEnumToJSON(value["deniedAction"]),
        authentication: AuthenticationEnumToJSON(value["authentication"]),
    };
}
