/* 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 { PartialGroup } from "./PartialGroup";
import { PartialGroupFromJSON } from "./PartialGroup";
import type { PartialUser } from "./PartialUser";
import { PartialUserFromJSON } from "./PartialUser";
import type { Policy } from "./Policy";
import { PolicyFromJSON } from "./Policy";

/**
 * PolicyBinding Serializer
 * @export
 * @interface PolicyBinding
 */
export interface PolicyBinding {
    /**
     *
     * @type {string}
     * @memberof PolicyBinding
     */
    readonly pk: string;
    /**
     *
     * @type {string}
     * @memberof PolicyBinding
     */
    policy?: string | null;
    /**
     *
     * @type {string}
     * @memberof PolicyBinding
     */
    group?: string | null;
    /**
     *
     * @type {number}
     * @memberof PolicyBinding
     */
    user?: number | null;
    /**
     *
     * @type {Policy}
     * @memberof PolicyBinding
     */
    readonly policyObj: Policy | null;
    /**
     *
     * @type {PartialGroup}
     * @memberof PolicyBinding
     */
    readonly groupObj: PartialGroup | null;
    /**
     *
     * @type {PartialUser}
     * @memberof PolicyBinding
     */
    readonly userObj: PartialUser | null;
    /**
     *
     * @type {string}
     * @memberof PolicyBinding
     */
    target: string;
    /**
     * Negates the outcome of the policy. Messages are unaffected.
     * @type {boolean}
     * @memberof PolicyBinding
     */
    negate?: boolean;
    /**
     *
     * @type {boolean}
     * @memberof PolicyBinding
     */
    enabled?: boolean;
    /**
     *
     * @type {number}
     * @memberof PolicyBinding
     */
    order: number;
    /**
     * Timeout after which Policy execution is terminated.
     * @type {number}
     * @memberof PolicyBinding
     */
    timeout?: number;
    /**
     * Result if the Policy execution fails.
     * @type {boolean}
     * @memberof PolicyBinding
     */
    failureResult?: boolean;
}

/**
 * Check if a given object implements the PolicyBinding interface.
 */
export function instanceOfPolicyBinding(value: object): value is PolicyBinding {
    if (!("pk" in value) || value["pk"] === undefined) return false;
    if (!("policyObj" in value) || value["policyObj"] === undefined) return false;
    if (!("groupObj" in value) || value["groupObj"] === undefined) return false;
    if (!("userObj" in value) || value["userObj"] === undefined) return false;
    if (!("target" in value) || value["target"] === undefined) return false;
    if (!("order" in value) || value["order"] === undefined) return false;
    return true;
}

export function PolicyBindingFromJSON(json: any): PolicyBinding {
    return PolicyBindingFromJSONTyped(json, false);
}

export function PolicyBindingFromJSONTyped(json: any, ignoreDiscriminator: boolean): PolicyBinding {
    if (json == null) {
        return json;
    }
    return {
        pk: json["pk"],
        policy: json["policy"] == null ? undefined : json["policy"],
        group: json["group"] == null ? undefined : json["group"],
        user: json["user"] == null ? undefined : json["user"],
        policyObj: PolicyFromJSON(json["policy_obj"]),
        groupObj: PartialGroupFromJSON(json["group_obj"]),
        userObj: PartialUserFromJSON(json["user_obj"]),
        target: json["target"],
        negate: json["negate"] == null ? undefined : json["negate"],
        enabled: json["enabled"] == null ? undefined : json["enabled"],
        order: json["order"],
        timeout: json["timeout"] == null ? undefined : json["timeout"],
        failureResult: json["failure_result"] == null ? undefined : json["failure_result"],
    };
}

export function PolicyBindingToJSON(json: any): PolicyBinding {
    return PolicyBindingToJSONTyped(json, false);
}

export function PolicyBindingToJSONTyped(
    value?: Omit<PolicyBinding, "pk" | "policy_obj" | "group_obj" | "user_obj"> | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }

    return {
        policy: value["policy"],
        group: value["group"],
        user: value["user"],
        target: value["target"],
        negate: value["negate"],
        enabled: value["enabled"],
        order: value["order"],
        timeout: value["timeout"],
        failure_result: value["failureResult"],
    };
}
