/* 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 { InvalidResponseActionEnum } from "./InvalidResponseActionEnum";
import {
    InvalidResponseActionEnumFromJSON,
    InvalidResponseActionEnumToJSON,
} from "./InvalidResponseActionEnum";
import type { PolicyEngineMode } from "./PolicyEngineMode";
import { PolicyEngineModeFromJSON, PolicyEngineModeToJSON } from "./PolicyEngineMode";
import type { Stage } from "./Stage";
import { StageFromJSON } from "./Stage";

/**
 * FlowStageBinding Serializer
 * @export
 * @interface FlowStageBinding
 */
export interface FlowStageBinding {
    /**
     *
     * @type {string}
     * @memberof FlowStageBinding
     */
    readonly pk: string;
    /**
     *
     * @type {string}
     * @memberof FlowStageBinding
     */
    readonly policybindingmodelPtrId: string;
    /**
     *
     * @type {string}
     * @memberof FlowStageBinding
     */
    target: string;
    /**
     *
     * @type {string}
     * @memberof FlowStageBinding
     */
    stage: string;
    /**
     *
     * @type {Stage}
     * @memberof FlowStageBinding
     */
    readonly stageObj: Stage;
    /**
     * Evaluate policies during the Flow planning process.
     * @type {boolean}
     * @memberof FlowStageBinding
     */
    evaluateOnPlan?: boolean;
    /**
     * Evaluate policies when the Stage is presented to the user.
     * @type {boolean}
     * @memberof FlowStageBinding
     */
    reEvaluatePolicies?: boolean;
    /**
     *
     * @type {number}
     * @memberof FlowStageBinding
     */
    order: number;
    /**
     *
     * @type {PolicyEngineMode}
     * @memberof FlowStageBinding
     */
    policyEngineMode?: PolicyEngineMode;
    /**
     * Configure how the flow executor should handle an invalid response to a challenge. RETRY returns the error message and a similar challenge to the executor. RESTART restarts the flow from the beginning, and RESTART_WITH_CONTEXT restarts the flow while keeping the current context.
     * @type {InvalidResponseActionEnum}
     * @memberof FlowStageBinding
     */
    invalidResponseAction?: InvalidResponseActionEnum;
}

/**
 * Check if a given object implements the FlowStageBinding interface.
 */
export function instanceOfFlowStageBinding(value: object): value is FlowStageBinding {
    if (!("pk" in value) || value["pk"] === undefined) return false;
    if (!("policybindingmodelPtrId" in value) || value["policybindingmodelPtrId"] === undefined)
        return false;
    if (!("target" in value) || value["target"] === undefined) return false;
    if (!("stage" in value) || value["stage"] === undefined) return false;
    if (!("stageObj" in value) || value["stageObj"] === undefined) return false;
    if (!("order" in value) || value["order"] === undefined) return false;
    return true;
}

export function FlowStageBindingFromJSON(json: any): FlowStageBinding {
    return FlowStageBindingFromJSONTyped(json, false);
}

export function FlowStageBindingFromJSONTyped(
    json: any,
    ignoreDiscriminator: boolean,
): FlowStageBinding {
    if (json == null) {
        return json;
    }
    return {
        pk: json["pk"],
        policybindingmodelPtrId: json["policybindingmodel_ptr_id"],
        target: json["target"],
        stage: json["stage"],
        stageObj: StageFromJSON(json["stage_obj"]),
        evaluateOnPlan: json["evaluate_on_plan"] == null ? undefined : json["evaluate_on_plan"],
        reEvaluatePolicies:
            json["re_evaluate_policies"] == null ? undefined : json["re_evaluate_policies"],
        order: json["order"],
        policyEngineMode:
            json["policy_engine_mode"] == null
                ? undefined
                : PolicyEngineModeFromJSON(json["policy_engine_mode"]),
        invalidResponseAction:
            json["invalid_response_action"] == null
                ? undefined
                : InvalidResponseActionEnumFromJSON(json["invalid_response_action"]),
    };
}

export function FlowStageBindingToJSON(json: any): FlowStageBinding {
    return FlowStageBindingToJSONTyped(json, false);
}

export function FlowStageBindingToJSONTyped(
    value?: Omit<FlowStageBinding, "pk" | "policybindingmodel_ptr_id" | "stage_obj"> | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }

    return {
        target: value["target"],
        stage: value["stage"],
        evaluate_on_plan: value["evaluateOnPlan"],
        re_evaluate_policies: value["reEvaluatePolicies"],
        order: value["order"],
        policy_engine_mode: PolicyEngineModeToJSON(value["policyEngineMode"]),
        invalid_response_action: InvalidResponseActionEnumToJSON(value["invalidResponseAction"]),
    };
}
