/* 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 { ModelEnum } from './ModelEnum';
import {
    ModelEnumFromJSON,
    ModelEnumFromJSONTyped,
    ModelEnumToJSON,
    ModelEnumToJSONTyped,
} from './ModelEnum';
import type { AppEnum } from './AppEnum';
import {
    AppEnumFromJSON,
    AppEnumFromJSONTyped,
    AppEnumToJSON,
    AppEnumToJSONTyped,
} from './AppEnum';
import type { EventActions } from './EventActions';
import {
    EventActionsFromJSON,
    EventActionsFromJSONTyped,
    EventActionsToJSON,
    EventActionsToJSONTyped,
} from './EventActions';

/**
 * Event Matcher Policy Serializer
 * @export
 * @interface EventMatcherPolicy
 */
export interface EventMatcherPolicy {
    /**
     * 
     * @type {string}
     * @memberof EventMatcherPolicy
     */
    readonly pk: string;
    /**
     * 
     * @type {string}
     * @memberof EventMatcherPolicy
     */
    name: string;
    /**
     * When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged.
     * @type {boolean}
     * @memberof EventMatcherPolicy
     */
    executionLogging?: boolean;
    /**
     * Get object component so that we know how to edit the object
     * @type {string}
     * @memberof EventMatcherPolicy
     */
    readonly component: string;
    /**
     * Return object's verbose_name
     * @type {string}
     * @memberof EventMatcherPolicy
     */
    readonly verboseName: string;
    /**
     * Return object's plural verbose_name
     * @type {string}
     * @memberof EventMatcherPolicy
     */
    readonly verboseNamePlural: string;
    /**
     * Return internal model name
     * @type {string}
     * @memberof EventMatcherPolicy
     */
    readonly metaModelName: string;
    /**
     * Return objects policy is bound to
     * @type {number}
     * @memberof EventMatcherPolicy
     */
    readonly boundTo: number;
    /**
     * Match created events with this action type. When left empty, all action types will be matched.
     * @type {EventActions}
     * @memberof EventMatcherPolicy
     */
    action?: EventActions | null;
    /**
     * Matches Event's Client IP (strict matching, for network matching use an Expression Policy)
     * @type {string}
     * @memberof EventMatcherPolicy
     */
    clientIp?: string | null;
    /**
     * Match events created by selected application. When left empty, all applications are matched.
     * @type {AppEnum}
     * @memberof EventMatcherPolicy
     */
    app?: AppEnum | null;
    /**
     * Match events created by selected model. When left empty, all models are matched. When an app is selected, all the application's models are matched.
     * @type {ModelEnum}
     * @memberof EventMatcherPolicy
     */
    model?: ModelEnum | null;
}



/**
 * Check if a given object implements the EventMatcherPolicy interface.
 */
export function instanceOfEventMatcherPolicy(value: object): value is EventMatcherPolicy {
    if (!('pk' in value) || value['pk'] === undefined) return false;
    if (!('name' in value) || value['name'] === undefined) return false;
    if (!('component' in value) || value['component'] === undefined) return false;
    if (!('verboseName' in value) || value['verboseName'] === undefined) return false;
    if (!('verboseNamePlural' in value) || value['verboseNamePlural'] === undefined) return false;
    if (!('metaModelName' in value) || value['metaModelName'] === undefined) return false;
    if (!('boundTo' in value) || value['boundTo'] === undefined) return false;
    return true;
}

export function EventMatcherPolicyFromJSON(json: any): EventMatcherPolicy {
    return EventMatcherPolicyFromJSONTyped(json, false);
}

export function EventMatcherPolicyFromJSONTyped(json: any, ignoreDiscriminator: boolean): EventMatcherPolicy {
    if (json == null) {
        return json;
    }
    return {
        
        'pk': json['pk'],
        'name': json['name'],
        'executionLogging': json['execution_logging'] == null ? undefined : json['execution_logging'],
        'component': json['component'],
        'verboseName': json['verbose_name'],
        'verboseNamePlural': json['verbose_name_plural'],
        'metaModelName': json['meta_model_name'],
        'boundTo': json['bound_to'],
        'action': json['action'] == null ? undefined : EventActionsFromJSON(json['action']),
        'clientIp': json['client_ip'] == null ? undefined : json['client_ip'],
        'app': json['app'] == null ? undefined : AppEnumFromJSON(json['app']),
        'model': json['model'] == null ? undefined : ModelEnumFromJSON(json['model']),
    };
}

export function EventMatcherPolicyToJSON(json: any): EventMatcherPolicy {
    return EventMatcherPolicyToJSONTyped(json, false);
}

export function EventMatcherPolicyToJSONTyped(value?: Omit<EventMatcherPolicy, 'pk'|'component'|'verbose_name'|'verbose_name_plural'|'meta_model_name'|'bound_to'> | null, ignoreDiscriminator: boolean = false): any {
    if (value == null) {
        return value;
    }

    return {
        
        'name': value['name'],
        'execution_logging': value['executionLogging'],
        'action': EventActionsToJSON(value['action']),
        'client_ip': value['clientIp'],
        'app': AppEnumToJSON(value['app']),
        'model': ModelEnumToJSON(value['model']),
    };
}

