/* 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 { BackendsEnum } from "./BackendsEnum";
import { BackendsEnumFromJSON, BackendsEnumToJSON } from "./BackendsEnum";

/**
 * PasswordStage Serializer
 * @export
 * @interface PasswordStageRequest
 */
export interface PasswordStageRequest {
    /**
     *
     * @type {string}
     * @memberof PasswordStageRequest
     */
    name: string;
    /**
     * Selection of backends to test the password against.
     * @type {Array<BackendsEnum>}
     * @memberof PasswordStageRequest
     */
    backends: Array<BackendsEnum>;
    /**
     * Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.
     * @type {string}
     * @memberof PasswordStageRequest
     */
    configureFlow?: string | null;
    /**
     * How many attempts a user has before the flow is canceled. To lock the user out, use a reputation policy and a user_write stage.
     * @type {number}
     * @memberof PasswordStageRequest
     */
    failedAttemptsBeforeCancel?: number;
    /**
     * When enabled, provides a 'show password' button with the password input field.
     * @type {boolean}
     * @memberof PasswordStageRequest
     */
    allowShowPassword?: boolean;
}

/**
 * Check if a given object implements the PasswordStageRequest interface.
 */
export function instanceOfPasswordStageRequest(value: object): value is PasswordStageRequest {
    if (!("name" in value) || value["name"] === undefined) return false;
    if (!("backends" in value) || value["backends"] === undefined) return false;
    return true;
}

export function PasswordStageRequestFromJSON(json: any): PasswordStageRequest {
    return PasswordStageRequestFromJSONTyped(json, false);
}

export function PasswordStageRequestFromJSONTyped(
    json: any,
    ignoreDiscriminator: boolean,
): PasswordStageRequest {
    if (json == null) {
        return json;
    }
    return {
        name: json["name"],
        backends: (json["backends"] as Array<any>).map(BackendsEnumFromJSON),
        configureFlow: json["configure_flow"] == null ? undefined : json["configure_flow"],
        failedAttemptsBeforeCancel:
            json["failed_attempts_before_cancel"] == null
                ? undefined
                : json["failed_attempts_before_cancel"],
        allowShowPassword:
            json["allow_show_password"] == null ? undefined : json["allow_show_password"],
    };
}

export function PasswordStageRequestToJSON(json: any): PasswordStageRequest {
    return PasswordStageRequestToJSONTyped(json, false);
}

export function PasswordStageRequestToJSONTyped(
    value?: PasswordStageRequest | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }

    return {
        name: value["name"],
        backends: (value["backends"] as Array<any>).map(BackendsEnumToJSON),
        configure_flow: value["configureFlow"],
        failed_attempts_before_cancel: value["failedAttemptsBeforeCancel"],
        allow_show_password: value["allowShowPassword"],
    };
}
