/* tslint:disable */
/* eslint-disable */
/**
 * authentik
 * Making authentication simple.
 *
 * The version of the OpenAPI document: 2025.10.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 { mapValues } from '../runtime';
import type { Policy } from './Policy';
import {
    PolicyFromJSON,
    PolicyFromJSONTyped,
    PolicyToJSON,
    PolicyToJSONTyped,
} from './Policy';
import type { Group } from './Group';
import {
    GroupFromJSON,
    GroupFromJSONTyped,
    GroupToJSON,
    GroupToJSONTyped,
} from './Group';
import type { User } from './User';
import {
    UserFromJSON,
    UserFromJSONTyped,
    UserToJSON,
    UserToJSONTyped,
} from './User';

/**
 * 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;
    /**
     * 
     * @type {Group}
     * @memberof PolicyBinding
     */
    readonly groupObj: Group;
    /**
     * 
     * @type {User}
     * @memberof PolicyBinding
     */
    readonly userObj: User;
    /**
     * 
     * @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': GroupFromJSON(json['group_obj']),
        'userObj': UserFromJSON(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'],
    };
}

