/* 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 { Connector } from "./Connector";
import { ConnectorFromJSON } from "./Connector";
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 DeviceUserBinding
 */
export interface DeviceUserBinding {
    /**
     *
     * @type {string}
     * @memberof DeviceUserBinding
     */
    readonly pk: string;
    /**
     *
     * @type {string}
     * @memberof DeviceUserBinding
     */
    policy?: string | null;
    /**
     *
     * @type {string}
     * @memberof DeviceUserBinding
     */
    group?: string | null;
    /**
     *
     * @type {number}
     * @memberof DeviceUserBinding
     */
    user?: number | null;
    /**
     *
     * @type {Policy}
     * @memberof DeviceUserBinding
     */
    readonly policyObj: Policy | null;
    /**
     *
     * @type {PartialGroup}
     * @memberof DeviceUserBinding
     */
    readonly groupObj: PartialGroup | null;
    /**
     *
     * @type {PartialUser}
     * @memberof DeviceUserBinding
     */
    readonly userObj: PartialUser | null;
    /**
     *
     * @type {string}
     * @memberof DeviceUserBinding
     */
    target: string;
    /**
     * Negates the outcome of the policy. Messages are unaffected.
     * @type {boolean}
     * @memberof DeviceUserBinding
     */
    negate?: boolean;
    /**
     *
     * @type {boolean}
     * @memberof DeviceUserBinding
     */
    enabled?: boolean;
    /**
     *
     * @type {number}
     * @memberof DeviceUserBinding
     */
    order: number;
    /**
     * Timeout after which Policy execution is terminated.
     * @type {number}
     * @memberof DeviceUserBinding
     */
    timeout?: number;
    /**
     * Result if the Policy execution fails.
     * @type {boolean}
     * @memberof DeviceUserBinding
     */
    failureResult?: boolean;
    /**
     *
     * @type {boolean}
     * @memberof DeviceUserBinding
     */
    isPrimary?: boolean;
    /**
     *
     * @type {string}
     * @memberof DeviceUserBinding
     */
    readonly connector: string | null;
    /**
     *
     * @type {Connector}
     * @memberof DeviceUserBinding
     */
    readonly connectorObj: Connector;
}

/**
 * Check if a given object implements the DeviceUserBinding interface.
 */
export function instanceOfDeviceUserBinding(value: object): value is DeviceUserBinding {
    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;
    if (!("connector" in value) || value["connector"] === undefined) return false;
    if (!("connectorObj" in value) || value["connectorObj"] === undefined) return false;
    return true;
}

export function DeviceUserBindingFromJSON(json: any): DeviceUserBinding {
    return DeviceUserBindingFromJSONTyped(json, false);
}

export function DeviceUserBindingFromJSONTyped(
    json: any,
    ignoreDiscriminator: boolean,
): DeviceUserBinding {
    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"],
        isPrimary: json["is_primary"] == null ? undefined : json["is_primary"],
        connector: json["connector"],
        connectorObj: ConnectorFromJSON(json["connector_obj"]),
    };
}

export function DeviceUserBindingToJSON(json: any): DeviceUserBinding {
    return DeviceUserBindingToJSONTyped(json, false);
}

export function DeviceUserBindingToJSONTyped(
    value?: Omit<
        DeviceUserBinding,
        "pk" | "policy_obj" | "group_obj" | "user_obj" | "connector" | "connector_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"],
        is_primary: value["isPrimary"],
    };
}
