/* 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 PatchedPasswordStageRequest
 */
export interface PatchedPasswordStageRequest {
    /**
     *
     * @type {string}
     * @memberof PatchedPasswordStageRequest
     */
    name?: string;
    /**
     * Selection of backends to test the password against.
     * @type {Array<BackendsEnum>}
     * @memberof PatchedPasswordStageRequest
     */
    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 PatchedPasswordStageRequest
     */
    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 PatchedPasswordStageRequest
     */
    failedAttemptsBeforeCancel?: number;
    /**
     * When enabled, provides a 'show password' button with the password input field.
     * @type {boolean}
     * @memberof PatchedPasswordStageRequest
     */
    allowShowPassword?: boolean;
}

/**
 * Check if a given object implements the PatchedPasswordStageRequest interface.
 */
export function instanceOfPatchedPasswordStageRequest(
    value: object,
): value is PatchedPasswordStageRequest {
    return true;
}

export function PatchedPasswordStageRequestFromJSON(json: any): PatchedPasswordStageRequest {
    return PatchedPasswordStageRequestFromJSONTyped(json, false);
}

export function PatchedPasswordStageRequestFromJSONTyped(
    json: any,
    ignoreDiscriminator: boolean,
): PatchedPasswordStageRequest {
    if (json == null) {
        return json;
    }
    return {
        name: json["name"] == null ? undefined : json["name"],
        backends:
            json["backends"] == null
                ? undefined
                : (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 PatchedPasswordStageRequestToJSON(json: any): PatchedPasswordStageRequest {
    return PatchedPasswordStageRequestToJSONTyped(json, false);
}

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

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